﻿using Ninject;
using Ninject.Syntax;
using System;
using System.Windows;

namespace HobSoft.SoccerBet2014.Client.Factory
{
    using Domain.Core;
    public interface IWindowFactory : IServiceFactory
    {
        T Create<T>() where T : Window;
        Window Create(Type type);
    }

    public class WindowFactory : IWindowFactory
    {
        private readonly IResolutionRoot _resolutionRoot;
        public WindowFactory(IResolutionRoot resolutionRoot)
        {
            _resolutionRoot = resolutionRoot;
        }

        public T Create<T>() where T : Window
        {
            return _resolutionRoot.Get<T>();
        }

        public Window Create(Type type)
        {
            if (!type.IsSubclassOf(typeof(Window))) throw new ArgumentException("必须是一个Wpf Window类型", "type");
            return (Window)_resolutionRoot.Get(type);
        }

        public object CreateOrGet()
        {
            throw new NotImplementedException();
        }
    }
}
